home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mint99s / proc.h < prev    next >
C/C++ Source or Header  |  1992-12-23  |  8KB  |  239 lines

  1. /*
  2. Copyright 1990,1991,1992 Eric R. Smith.
  3. Copyright 1992 Atari Corporation.
  4. All rights reserved.
  5. */
  6.  
  7. /* proc.h: defines for various process related things */
  8. #ifndef _proc_h
  9. #define _proc_h
  10.  
  11. #include "file.h"
  12.  
  13. /* a process context consists, for now, of its registers */
  14.  
  15. typedef struct _context {
  16.     long    regs[15];    /* registers d0-d7, a0-a6 */
  17.     long    usp;        /* user stack pointer (a7) */
  18.     short    sr;        /* status register */
  19.     long    pc;        /* program counter */
  20.     long    ssp;        /* supervisor stack pointer */
  21.     long    term_vec;    /* GEMDOS terminate vector (0x102) */
  22. /*
  23.  * AGK: if running on a TT and the user is playing with the FPU then we
  24.  * must save and restore the context. We should also consider this for
  25.  * I/O based co-processors, although this may be difficult due to
  26.  * possibility of a context switch in the middle of an I/O handshaking
  27.  * exchange.
  28.  */
  29.     unsigned char    fstate[216];    /* FPU internal state */
  30.     long    fregs[3*8];    /* registers fp0-fp7 */
  31.     long    fctrl[3];    /* FPCR/FPSR/FPIAR */
  32.     char    ptrace;        /* trace exception is pending */
  33.     char    pad1;        /* junk */
  34.     long    iar;        /* unused */
  35.     short    res[4];        /* unused, reserved */
  36. /*
  37.  * Saved CRP and TC values.  These are necessary for memory protection.
  38.  */
  39.  
  40.     crp_reg crp;            /* 64 bits */
  41.     tc_reg tc;            /* 32 bits */
  42. /*
  43.  * AGK: for long (time-wise) co-processor instructions (FMUL etc.), the
  44.  * FPU returns NULL, come-again with interrupts allowed primitives. It
  45.  * is highly likely that a context switch will occur in one of these if
  46.  * running a mathematically intensive application, hence we must handle
  47.  * the mid-instruction interrupt stack. We do this by saving the extra
  48.  * 3 long words and the stack format word here.
  49.  */
  50.     unsigned short    sfmt;    /* stack frame format identifier */
  51.     short    internal[42];    /* internal state -- see framesizes[] for size */
  52. } CONTEXT;
  53.  
  54. #define PROC_CTXTS    2
  55. #define SYSCALL        0    /* saved context from system call    */
  56. #define CURRENT        1    /* current saved context        */
  57.  
  58. /*
  59.  * Timeout events are stored in a list; the "when" field in the event
  60.  * specifies the number of milliseconds *after* the last entry in the
  61.  * list that the timeout should occur, so routines that manipulate
  62.  * the list only need to check the first entry.
  63.  */
  64.  
  65. typedef struct timeout {
  66.     struct timeout *next;
  67.     struct proc    *proc;
  68.     long    when;
  69.     void    (*func) P_((struct proc *)); /* function to call at timeout */
  70. } TIMEOUT;
  71.  
  72. #ifndef GENMAGIC
  73. extern TIMEOUT *tlist;
  74. #endif
  75.  
  76. #define NUM_REGIONS    64    /* number of memory regions alloced at a time */
  77. #define MIN_HANDLE    (-5)    /* minimum handle number        */
  78. #define MIN_OPEN    6    /* 0..MIN_OPEN-1 are reserved for system */
  79. #define MAX_OPEN    32    /* max. number of open files for a proc    */
  80. #define SSTKSIZE    8000    /* size of supervisor stack (in bytes)     */
  81. #define ISTKSIZE    2000    /* size of interrupt stack (in bytes)    */
  82. #define STKSIZE        (ISTKSIZE + SSTKSIZE)
  83.  
  84. #define FRAME_MAGIC    0xf4a3e000UL
  85.                 /* magic for signal call stack */
  86. #define CTXT_MAGIC    0xabcdef98UL
  87. #define CTXT2_MAGIC    0x87654321UL
  88.                 /* magic #'s for contexts */
  89.  
  90. #define PNAMSIZ        8    /* no. of characters in a process name */
  91.  
  92. #define DOM_TOS        0    /* TOS process domain */
  93. #define DOM_MINT    1    /* MiNT process domain */
  94.  
  95. typedef struct proc {
  96.     long    sysstack;        /* must be first        */
  97.     CONTEXT    ctxt[PROC_CTXTS];    /* must be second        */
  98.  
  99. /* this is stuff that the public can know about */
  100.     long    magic;            /* validation for proc struct    */
  101.  
  102.     BASEPAGE *base;            /* process base page        */
  103.     short    pid, ppid, pgrp;
  104.     short    ruid;            /* process real user id     */
  105.     short    rgid;            /* process real group id     */
  106.     short    euid, egid;        /* effective user and group ids */
  107.  
  108.     ushort    memflags;        /* e.g. malloc from alternate ram */
  109.     short    pri;            /* base process priority     */
  110.     short    wait_q;            /* current process queue    */
  111.  
  112. /* note: wait_cond should be unique for each kind of condition we might
  113.  * want to wait for. Put a define below, or use an address in the
  114.  * kernel as the wait condition to ensure uniqueness.
  115.  */
  116.     long    wait_cond;        /* condition we're waiting on    */
  117.                     /* (also return code from wait) */
  118.  
  119. #define WAIT_MB        0x3a140001L    /* wait_cond for p_msg call    */
  120. #define WAIT_SEMA    0x3a140003L    /* wait_cond for p_semaphore    */
  121.  
  122.     /* (all times are in milliseconds) */
  123.     /* usrtime must always follow systime */
  124.     ulong    systime;        /* time spent in kernel        */
  125.     ulong    usrtime;        /* time spent out of kernel    */
  126.     ulong    chldstime;        /* children's kernel time     */
  127.     ulong    chldutime;        /* children's user time        */
  128.  
  129.     ulong    maxmem;            /* max. amount of memory to use */
  130.     ulong    maxdata;        /* max. data region for process */
  131.     ulong    maxcore;        /* max. core memory for process */
  132.     ulong    maxcpu;            /* max. cpu time to use     */
  133.  
  134.     short    domain;            /* process domain (TOS or UNIX)    */
  135.  
  136.     short    curpri;            /* current process priority    */
  137. #define MIN_NICE -20
  138. #define MAX_NICE 20
  139.  
  140. /* EVERYTHING BELOW THIS LINE IS SUBJECT TO CHANGE:
  141.  * programs should *not* try to read this stuff via the U:\PROC dir.
  142.  */
  143.  
  144.     char    name[PNAMSIZ+1];    /* process name            */
  145.     TIMEOUT    *alarmtim;        /* alarm() event        */
  146.     short    slices;            /* number of time slices before this
  147.                        process gets to run again */
  148.  
  149.     short    bconmap;        /* Bconmap mapping        */
  150.     FILEPTR *midiout;        /* MIDI output            */
  151.     FILEPTR *midiin;        /* MIDI input            */
  152.     FILEPTR    *prn;            /* printer            */
  153.     FILEPTR *aux;            /* auxiliary tty        */
  154.     FILEPTR    *control;        /* control tty            */
  155.     FILEPTR    *handle[MAX_OPEN];    /* file handles            */
  156.  
  157.     uchar    fdflags[MAX_OPEN];    /* file descriptor flags    */
  158.  
  159.     ushort    num_reg;        /* number of memory regions allocated */
  160.     MEMREGION **mem;        /* allocated memory regions    */
  161.     virtaddr *addr;            /* addresses of regions        */
  162.  
  163.     ulong    sigpending;        /* pending signals        */
  164.     ulong    sigmask;        /* signals that are masked    */
  165.     ulong    sighandle[NSIG];    /* signal handlers        */
  166.     ushort    sigflags[NSIG];        /* signal flags            */
  167.     ulong    sigextra[NSIG];        /* additional signals to be masked
  168.                        on delivery     */
  169.     char    *mb_ptr;        /* p_msg buffer ptr        */
  170.     long    mb_long1, mb_long2;    /* p_msg storage        */
  171.     long    mb_mbid;        /* p_msg id being waited for    */
  172.     short    mb_mode;        /* p_msg mode being waiting in    */
  173.     short    mb_writer;        /* p_msg pid of writer of msg    */
  174.  
  175.     short    curdrv;            /* current drive        */
  176.     fcookie root[NUM_DRIVES];    /* root directories        */
  177.     fcookie    curdir[NUM_DRIVES];    /* current directory        */
  178.  
  179.     long    usrdata;        /* user-supplied data        */
  180.     ushort    umask;            /* file creation mask        */
  181.  
  182.     DTABUF    *dta;            /* current DTA            */
  183. #define NUM_SEARCH    6        /* max. number of searches    */
  184.     DTABUF *srchdta[NUM_SEARCH];    /* for Fsfirst/next        */
  185.     DIR    srchdir[NUM_SEARCH];    /* for Fsfirst/next        */
  186.     long    srchtim[NUM_SEARCH];    /* for Fsfirst/next        */
  187.     
  188.     DIR    *searches;        /* open directory searches    */
  189.  
  190.     long    txtsize;        /* size of text region (for fork()) */
  191.  
  192.     long ARGS_ON_STACK (*criticerr) P_((long)); /* critical error handler    */
  193.     void    *logbase;        /* logical screen base        */
  194.  
  195.     struct proc *ptracer;        /* process which is tracing this one */
  196.     short    ptraceflags;        /* flags for process tracing */
  197.     short    starttime;        /* time and date when process    */
  198.     short    startdate;        /* was started            */
  199.  
  200.     void    *page_table;        /* rounded page table pointer    */
  201.     void    *pt_mem;        /* original kmalloc'd block for above */
  202.  
  203.     ulong    exception_pc;        /* pc at time of bombs        */
  204.     ulong    exception_ssp;        /* ssp at time of bomb (e.g. bus error)    */
  205.     ulong    exception_tbl;        /* table in use at exception time */
  206.     ushort    exception_mmusr;    /* result from ptest insn    */
  207.     ulong    exception_addr;        /* access address from stack    */
  208.  
  209.     struct    proc *q_next;        /* next process on queue    */
  210.     struct     proc *gl_next;        /* next process in system    */
  211.     char    stack[STKSIZE+4];    /* stack for system calls    */
  212. } PROC;
  213.  
  214.  
  215. /* different process queues */
  216.  
  217. #define CURPROC_Q    0
  218. #define READY_Q        1
  219. #define WAIT_Q        2
  220. #define IO_Q        3
  221. #define ZOMBIE_Q    4
  222. #define TSR_Q        5
  223. #define STOP_Q        6
  224. #define SELECT_Q    7
  225.  
  226. #define NUM_QUEUES    8
  227.  
  228. #ifndef GENMAGIC
  229. extern PROC *proclist;            /* list of all active processes */
  230. extern PROC *curproc;            /* current process        */
  231. extern PROC *rootproc;            /* pid 0 -- MiNT itself        */
  232. extern PROC *sys_q[NUM_QUEUES];        /* process queues        */
  233.  
  234. extern long page_table_size;
  235.  
  236. #endif
  237.  
  238. #endif /* _proc_h */
  239.